﻿namespace Cap
{
    internal class EndpointBuilder : IEndpointBuilder
    {
        private List<Func<EventDelegate, EventDelegate>> _components = new();

        public EventDelegate Build()
        {
            EventDelegate app = context =>
            {
                throw new NotImplementedException();
            };
            for (int i = _components.Count - 1; i > -1; i--)
            {
                app = _components[i](app);
            }
            return app;
        }

        public void Use(Func<EventDelegate, EventDelegate> middleware)
        {
            _components.Add(middleware);
        }
    }
}
